﻿<phone:PhoneApplicationPage 
    x:Class="Wulong.Phone.Dianping.Views.SearchView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True"
    Style="{StaticResource TransitionPageStyle}"
    >
    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Name="PickerItemTemplate">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Name}" 
                           Style="{StaticResource PhoneTextNormalStyle}"/>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Name="PickerFullModeItemTemplate">
            <StackPanel Orientation="Horizontal" 
                            Margin="12,0">
                <Image Source="{Binding ImageUrl}"
                    Margin="12,0" />
                <TextBlock Text="{Binding Name}" 
                           Style="{StaticResource PhoneTextExtraLargeStyle}"/>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Name="PickeHeaderTemplate">
            <TextBlock 
                Text="{Binding Path=Appi18n.Choose_Categories, Source={StaticResource ls}}"
                Style="{StaticResource PhoneTextNormalStyle}"
                Foreground="#4f391e"/>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush ImageSource="/Images/PageBackground.png"/>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" 
                    Grid.Row="0" 
                    Margin="12,17,0,28"
                    Orientation="Horizontal">
            <TextBlock 
                x:Name="ApplicationTitle" 
                Text="{Binding Path=Appi18n.App_Title, Source={StaticResource ls}}" 
                Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock 
                x:Name="PageTitle" 
                Text="{Binding Path=Appi18n.Btn_Search, Source={StaticResource ls}}" 
                Style="{StaticResource PhoneTextNormalStyle}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" 
              Grid.Row="1" 
              Margin="12,0,12,0">
            <StackPanel>
                <StackPanel Orientation="Horizontal">
                    <toolkit:AutoCompleteBox 
                    x:Name="Search"
                    IsTextCompletionEnabled="True"
                    Text="{Binding Keywords, Mode=TwoWay}"
                    Width="360"
                    >
                        <toolkit:AutoCompleteBox.Background>
                            <RadialGradientBrush RadiusX="-0.3" Opacity="0.5">
                                <GradientStop Color="#FF8D5124" Offset="1"/>
                                <GradientStop Color="#FFBE9063"/>
                            </RadialGradientBrush>
                        </toolkit:AutoCompleteBox.Background>
                        <toolkit:AutoCompleteBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal"
                                        Margin="5,5,5,5"
                                        >
                                    <TextBlock 
                                    Text="{Binding Path=Name}"
                                    FontSize="26"/>
                                    <TextBlock Text="{Binding Path=ResultCount}"
                                           FontSize="26"/>
                                </StackPanel>
                            </DataTemplate>
                        </toolkit:AutoCompleteBox.ItemTemplate>
                    </toolkit:AutoCompleteBox>
                    <Button
                        Style="{StaticResource NoBorderBtnStyle}"
                        cal:Message.Attach="[Event Click]=[Action Search]">
                        <Button.ContentTemplate>
                            <DataTemplate>
                                <Image Source="/Images/BtnSearch.png"/>
                            </DataTemplate>
                        </Button.ContentTemplate>
                    </Button>
                </StackPanel>
                
                <StackPanel Orientation="Horizontal">
                    <toolkit:ListPicker 
                        x:Name="Channels" 
                        HeaderTemplate="{StaticResource PickeHeaderTemplate}" 
                        FullModeItemTemplate="{StaticResource PickerFullModeItemTemplate}" 
                        ItemTemplate="{StaticResource PickerItemTemplate}" 
                        SelectedItem="{Binding SelectedChannel, Mode=TwoWay}"
                        HorizontalAlignment="Left">
                        <toolkit:ListPicker.Background>
                            <RadialGradientBrush 
                                RadiusX="0.7" 
                                RadiusY="0.8" 
                                Opacity="0.5">
                                <GradientStop Color="#FF8D5124" Offset="1"/>
                                <GradientStop Color="#FFBE9063"/>
                            </RadialGradientBrush>
                        </toolkit:ListPicker.Background>
                    </toolkit:ListPicker>
                    <toolkit:ListPicker 
                        x:Name="Cities" 
                        HeaderTemplate="{StaticResource CityPickeHeaderTemplate}" 
                        FullModeItemTemplate="{StaticResource CityPickerFullModeItemTemplate}" 
                        ItemTemplate="{StaticResource CityPickerItemTemplate}" 
                        SelectedItem="{Binding SelectedCity, Mode=TwoWay}"
                        HorizontalAlignment="Left">
                        <toolkit:ListPicker.Background>
                            <RadialGradientBrush 
                                RadiusX="0.7" 
                                RadiusY="0.8" 
                                Opacity="0.5">
                                <GradientStop Color="#FF8D5124" Offset="1"/>
                                <GradientStop Color="#FFBE9063"/>
                            </RadialGradientBrush>
                        </toolkit:ListPicker.Background>
                    </toolkit:ListPicker>
                </StackPanel>
            </StackPanel>
        </Grid>
        <ListBox 
            x:Name="SearchCandidates"
            Grid.Row="2" 
            Width="450"
            HorizontalAlignment="Left" 
            Style="{StaticResource MerchantListBoxStyle}" 
            ItemTemplate="{StaticResource MerchantListItemTemplate}"
            SelectedItem="{Binding SelectedResult, Mode=TwoWay}"
            cal:Message.Attach="[Event SelectionChanged]=[Action MerchantDetail]"
            >
            
        </ListBox>
    </Grid>
 
    <shell:SystemTray.ProgressIndicator>
        <shell:ProgressIndicator 
            IsIndeterminate="{Binding IsBusy}" 
            IsVisible="{Binding IsBusy}"
            Text="{Binding Path=Appi18n.Loading, Source={StaticResource ls}}"/>
    </shell:SystemTray.ProgressIndicator>
</phone:PhoneApplicationPage>
